package com.doordu.framework.cloud.xxl.manager;

import com.doordu.framework.cloud.xxl.DoorduJobInstanceConfig;
import com.xxl.job.core.executor.XxlJobExecutor;
import com.xxl.job.core.handler.IJobHandler;

/**
 * @author zxw
 * @date 2020/9/22 23:31
 */
public class ExecutorManager {
    private XxlJobExecutor xxlJobExecutor;
    private DoorduJobInstanceConfig doorduJobInstanceConfig;

    public ExecutorManager(XxlJobExecutor xxlJobExecutor, DoorduJobInstanceConfig doorduJobInstanceConfig) {
        this.xxlJobExecutor = xxlJobExecutor;
        this.doorduJobInstanceConfig = doorduJobInstanceConfig;
    }

    private static ExecutorManager instance = new ExecutorManager(null, null);

    public XxlJobExecutor getXxlJobExecutor() {
        return this.xxlJobExecutor;
    }

    public DoorduJobInstanceConfig getDoorduJobInstanceConfig() {
        return this.doorduJobInstanceConfig;
    }

    public void registerExecutor(String name, IJobHandler jobHandler) {
        XxlJobExecutor.registJobHandler(name, jobHandler);
    }
}
